package com.kehao.leetcode.basic.string;

import org.junit.Test;

public class StringSolution2 {
    public int reverse(int x) {
        int gewei;
        int result =0;
        int newResult;
        while (x!=0){
           gewei = x % 10;
           newResult = result*10+gewei;
           if((newResult-gewei)/10!=result)
               return 0;
           result = newResult;
           x = x/10;
        }
        return result;
    }

    @Test
    public void myTest(){
        System.out.println(reverse(123));
    }
}
